﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnovTech.Net.DataTransfer
{
    public class DataTransferConfig : ConnectionConfig, IDataTransferConfig
    {
        public static readonly object TransferStartingKey = "the key of the envet handler TransferStarting";
        public static readonly object TransferInitializedKey = "the key of the envet handler TransferInitialized";
        public static readonly object TransferConnectingKey = "the key of the envet handler TransferConnecting";
        public static readonly object TransferingKey = "the key of the envet handler Transfering";
        public static readonly object TransferCanceledKey = "the key of the envet handler TransferCanceled";
        public static readonly object TransferErrorKey = "the key of the envet handler TransferError";
        public static readonly object TransferCompletedKey = "the key of the envet handler TransferCompleted";
        public static readonly object StateChangedKey = "the key of the envet handler StateChanged";

        public static readonly object ShouldRetryKey = "the key of the should retry";
        public static readonly object RetryIntervalKey = "the key of the interval of the should retry";
        public static readonly object TestMD5Key = "the key of the testing MD5";
        public static readonly object ServerFilePathKey = "the key of the file path of the server for the data";
        public static readonly object TransferOffsetKey = "the key of the offset to start data transfer";
        public static readonly object LocalFilePathKey = "the key of the local file path";


        public EventHandler<DataTransferStartingEventArgs> TransferStarting
        {
            get
            {
                return GetValue(TransferStartingKey) as EventHandler<DataTransferStartingEventArgs>;
            }
            set
            {
                SetValue(TransferStartingKey, value);
            }
        }

        public EventHandler<DataTransferInitializedEventArgs> TransferInitialized
        {
            get
            {
                return GetValue(TransferInitializedKey) as EventHandler<DataTransferInitializedEventArgs>;
            }
            set
            {
                SetValue(TransferInitializedKey, value);
            }
        }

        public EventHandler<DataTransferConnectingEventArgs> TransferConnecting
        {
            get
            {
                return GetValue(TransferConnectingKey) as EventHandler<DataTransferConnectingEventArgs>;
            }
            set
            {
                SetValue(TransferConnectingKey, value);
            }
        }

        public EventHandler<DataTransferingEventArgs> Transfering
        {
            get
            {
                return GetValue(TransferingKey) as EventHandler<DataTransferingEventArgs>;
            }
            set
            {
                SetValue(TransferingKey, value);
            }
        }

        public EventHandler<DataTransferCanceledEventArgs> TransferCanceled
        {
            get
            {
                return GetValue(TransferCanceledKey) as EventHandler<DataTransferCanceledEventArgs>;
            }
            set
            {
                SetValue(TransferCanceledKey, value);
            }
        }

        public EventHandler<DataTransferErrorEventArgs> TransferError
        {
            get
            {
                return GetValue(TransferErrorKey) as EventHandler<DataTransferErrorEventArgs>;
            }
            set
            {
                SetValue(TransferErrorKey, value);
            }
        }

        public EventHandler<DataTransferCompletedEventArgs> TransferCompleted
        {
            get
            {
                return GetValue(TransferCompletedKey) as EventHandler<DataTransferCompletedEventArgs>;
            }
            set
            {
                SetValue(TransferCompletedKey, value);
            }
        }

        public EventHandler<DataTransferStateChangedEventArgs> StateChanged
        {
            get
            {
                return GetValue(StateChangedKey) as EventHandler<DataTransferStateChangedEventArgs>;
            }
            set
            {
                SetValue(StateChangedKey, value);
            }
        }

        public bool ShouldRetry
        {
            get
            {
                return GetValue(ShouldRetryKey) == null ? false : (bool)GetValue(ShouldRetryKey);
            }
            set
            {
                SetValue(ShouldRetryKey, value);
            }
        }

        public TimeSpan RetryInterval
        {
            get
            {
                return GetValue(RetryIntervalKey) == null ? default(TimeSpan) : (TimeSpan)GetValue(RetryIntervalKey);
            }
            set
            {
                SetValue(RetryIntervalKey, value);
            }
        }

        public bool TestMD5
        {
            get
            {
                return GetValue(TestMD5Key) == null ? false : (bool)GetValue(TestMD5Key);
            }
            set
            {
                SetValue(TestMD5Key, value);
            }
        }

        public string ServerFilePath
        {
            get
            {
                return GetValue(ServerFilePathKey) as string;
            }
            set
            {
                SetValue(ServerFilePathKey, value);
            }
        }

        public long TransferOffset
        {
            get
            {
                return GetValue(TransferOffsetKey) == null ? 0 : (long)GetValue(TransferOffsetKey);
            }
            set
            {
                SetValue(TransferOffsetKey, value);
            }
        }

        public string LocalFilePath
        {
            get
            {
                return GetValue(LocalFilePathKey) as string;
            }
            set
            {
                SetValue(LocalFilePathKey, value);
            }
        }

    }
}
